package mvc.controller;

import java.awt.event.MouseEvent;

import mvc.model.IModelCurve;
import mvc.view.ViewCurve;

import org.geom.Maths;
import org.geom.curve.Curve;


public abstract class ControllerMouse3D extends MouseController {

	public ControllerMouse3D(IModelCurve model, ViewCurve view, String param) {
		super(model, view, param);
	}

	@Override
	public void mouseDragged(MouseEvent e) {
		super.mouseDragged(e);
		
		switch(action) {
		case SCALE: 
			view.setScale(deltay, deltay);
			break;
		case TRANSLATE: 
			view.setTranslate(deltax, deltay);
			break;
		case ROTATE:
			view.setRotate(deltax, deltay);
			break;
		}
		
		view.repaint();
	}

	@Override
	public void mouseMoved(MouseEvent e) {
		setCurrentPoint(e.getY());
	}

	private void setCurrentPoint(int y) {
		model.setCurrentPoint(Maths.mapProportion(y, 
									0, view.getHeight(), 0, 
									Curve.length*model.getArc()));
		view.repaint();
	}

}